import random
import time

def memory_intensive_task(size, accesses):
    list = []
    for i in range(size):
        list.append(1)

    for i in range(accesses):
        index = random.randint(0, size-1)
        list[index] += 1

    return list

if __name__ == "__main__":
    N = 2 * 1024 * 10 ** 5
    accesses = 10**9
    
    print("开始测试...")
    start_time = time.time()
    
    result_array = memory_intensive_task(N, accesses)
    
    end_time = time.time()
    elapsed_time = end_time - start_time
    memory_access_per_second = accesses / elapsed_time
    
    print(f"测试完毕，用时: {elapsed_time:.2f} 秒.")
    print(f"平均每秒读取次数: {memory_access_per_second:.2f}")
